rem -----------------------------------------------------------------------
rem Startup batch file for Billing System Application
rem -----------------------------------------------------------------------

@echo off
cls
rem echo %JAVA_HOME%
rem ---------------------------------------------------------------------------
rem Please Set the JAVA HOME here 
rem Eg : JAVA_HOME=C:\Program Files\Java\jdk1.6.0_18
rem Eg : JAVA_HOME=C:\jdk1.6.0_18
rem Eg : JAVA_HOME=C:\j2sdk1.5.2_07
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_18
rem ---------------------------------------------------------------------------

if "%JAVA_HOME%" == ""  goto notOkHome

set CURRENT_DIR=%cd%
set CLASSPATH=%CLASSPATH%;%JAVA_HOME%;%CURRENT_DIR%/lib/junit-4.0.jar;
set COMPILEJAVA="%JAVA_HOME%\bin\javac"
set EXECUTEJAVA="%JAVA_HOME%\bin\java"
set GENERATEJAR="%JAVA_HOME%\bin\jar"
set OUTPUT_CLASS_OPTION=-d  ..\bin

IF NOT EXIST bin mkdir bin

IF EXIST billingsystem.jar goto runApp

cd src
echo Compiling.....
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/constant/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/controller/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/datastore/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/datastore/impl/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/entity/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/entity/service/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/entity/transaction/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/exception/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/gui/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/gui/component/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/gui/subscription/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/localization/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/parse/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/privilege/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/template/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/template/interfaces/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/util/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/billing/validation/*.java
echo Compilation done

echo Creating JAR file.....
cd ../bin
%GENERATEJAR% cf ../billingsystem.jar sg
echo Creating JAR file DONE.

:runApp
echo Running App
cd %CURRENT_DIR% 
%EXECUTEJAVA% -classpath "billingsystem.jar;%CLASSPATH%" sg.edu.nus.iss.billing.gui.MainFrame
cd %CURRENT_DIR% 
goto end

:notOkHome
echo JAVA NOT AVAILABLE , PLEASE SET THE JAVA_HOME
:end
